<script setup>
import {reactive, ref} from 'vue'
import router from "@/router";
import { Schedules } from "@/store/Schedule";

const schedules = Schedules().schedules;
const task = router.currentRoute.value.query.task;
const scheduleToEdit = schedules.find(schedule => schedule.task === String(task));

const onSubmit = () => {
  router.push('/travel/Scheduling');
}

const returnLast = () => {
  router.push('/travel/Scheduling');
}
</script>

<template>
  <div class="main-container">
    <div class="form-container">
      <div style="font-size: 25px; color: #009dff; font-weight: bolder; width: 100%; text-align:center; margin: 0 0 20px 0">编 辑 行 程</div>

      <el-form class="form" :model="scheduleToEdit" label-width="auto" style="max-width: 600px">
        <el-form-item label="行程地点">
          <el-input v-model="scheduleToEdit.location" />
        </el-form-item>
        <el-form-item label="行程任务">
          <el-input v-model="scheduleToEdit.task" />
        </el-form-item>
        <el-form-item label="行程时间">
          <el-col :span="11">
            <el-date-picker
                v-model="scheduleToEdit.date1"
                type="date"
                placeholder="开始时间"
                style="width: 100%"
            />
          </el-col>
          <el-col :span="2" class="text-center" style="font-size: 20px; color: #181818; text-align: center; width: 100%">~</el-col>
          <el-col :span="11">
            <el-date-picker
                v-model="scheduleToEdit.date2"
                type="date"
                placeholder="结束时间"
                style="width: 100%"
            />
          </el-col>
        </el-form-item>
        <el-form-item label="行程详情">
          <el-input v-model="scheduleToEdit.detail" type="textarea" />
        </el-form-item>
        <el-form-item style="width: 100%; align-items: center">
          <div style="margin: 10px auto 0;">
            <el-button class="button" type="primary" @click="onSubmit" size="large">保 存</el-button>
            <el-button class="button" size="large" @click="returnLast">取 消</el-button>
          </div>
        </el-form-item>
      </el-form>
    </div>
  </div>

</template>

<style>
.main-container{
  width: 100%;
}
.form-container{
  margin: 10px auto auto;
  width: 55%;
  padding: 2% 5%;
  border-radius: 20px;
  box-shadow: 0px 0px 15px 0px rgba(122, 122, 122, 0.3);
  -webkit-box-shadow: 0px 0px 15px 0px rgba(122, 122, 122, 0.3);
  -moz-box-shadow: 0px 0px 15px 0px rgba(122, 122, 122, 0.3);
}
.form{
  margin: 0 auto;
}
.button{
  margin: 0 auto;
}
</style>